package com.leyou.load.controller;


import com.leyou.load.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("upload")
public class UploadController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("image")
    public ResponseEntity<String> uploadImage(@RequestParam("file")MultipartFile file) {


//        String path = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1542380662467&di=0e68de711c8ded43926e4581884dd2fe&imgtype=0&src=http%3A%2F%2Fpic24.photophoto.cn%2F20120925%2F0036036335775597_b.jpg";

        String path = this.uploadService.upload(file);

        return ResponseEntity.ok(path);
//        return ResponseEntity.status(HttpStatus.CREATED).build();

    }
}
